
<template>
    <div class="SportTime">
        <form-and-table :columns="columns" :schema="schema" ref="formAndTable"> </form-and-table>
    </div>
</template>

<script>
    import formAndTable from "@/components/TableAndForm";
    import {Gender} from "@/const/index";
    import { queryListByKeyValue, toPointer } from "@/api/baseApi";
    import standardMixin from "../standardMixin";
    // 体育课目时间表
    // const SportTimeSchema = new Schema({
    //  standard: { type: Schema.Types.ObjectId, ref: 'TrainStandard' },    // 训练大纲
    // 	sportCategory: String,                                  // 体育科目分类
    //  physicalLevel: String,                                  // 体能训练等级
    //  hours: Number,                                          // 时间要求
    // });
    export default {
        name: "category",
        components: {
            formAndTable
        },
        mixins: [standardMixin],
        data() {
            return {
                columns: [
                    {prop: 'sportCategory', label: '课目分类'},
                    {prop: 'physicalLevel', label: '训练等级'},
                    {prop: 'hour', label: '（小时）时间要求'},
                ],
                schema: [
                    {fieldType: "select", required: true, placeholder: "课目分类", label: "课目分类", vModel: "sportCategory", sportCategory: '',options: [],},
                    {fieldType: "select", required: true, placeholder: "训练等级", label: "训练等级", vModel: "physicalLevel", physicalLevel: '',options: [],},
                    {fieldType: "input-number", required: true, placeholder: "时间要求", label: "时间要求", vModel: "hour",hour: 0},
                ]
            }
        },
        async created(){
            // setTimeout(_=>{this.schema[0].standard = this.$parent.standard.name},500);
            // this.schemaPhysicalLevel.options = (await queryListByKeyValue('PhysicalLevel')).list;
            // this.schemaSportCategory.options = (await queryListByKeyValue('SportCategory')).list;
            setTimeout(async () => {
                this.schemaPhysicalLevel.options = await queryListByKeyValue("PhysicalLevel");
                this.schemaSportCategory.options = await queryListByKeyValue("SportCategory");
            }, 500);
        },
        computed:{
            schemaPhysicalLevel(){
                return this.schema.find(item=>item.vModel === 'physicalLevel')
            },
            schemaSportCategory(){
                return this.schema.find(item=>item.vModel === 'sportCategory')
            },
        },
        methods: {
            // beforeSubmit(formData) {
            //     formData.standard = this.$parent.standard.objectId;
            // },
            // beforeEdit(row){
            //     row.standard = this.$parent.standard.name;
            // }
        },
    }
</script>

